package com.cfuture08.util;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.List;

public class BeanUtil {
	public static String checkFieldNull(ReflectUtil ru, String[] match,
			List<String> except) throws Exception {
		String result = null;
		StringBuilder sb = new StringBuilder();
		Field[] fields = ru.getFields();
		for (Field f : fields) {
			String n = f.getName();
			Method m = ru.getMethod("get" + StringUtil.toUpCaseFirst(n));
			if (m != null) {
				Object v = m.invoke(ru.getObject());

				if (!except.contains(n)) {
					for (String mat : match) {
						if (mat.equals(v) || v == null) {
							sb.append(n).append("=").append(v).append("\n");
						}
					}
				}
			}
		}
		result = sb.toString();
		if (!"".equals(result)) {
			result = ru.getName() + "\n" + result;
		}
		return result;
	}
}
